# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from .Licence import *

class LicenceAdmin(object):
    list_display = []
    object_list_template = "licence.html"

    def post(self, request, *args, **kwargs):
        action = request.POST.get("lice")
        if action == "":
            self.message_user(u'许可不能为空!', 'warning')
        else:
            ls = LicensesSum(action)
            if ls == 0:
                self.message_user(u'未找到SIP用户许可，注册码：' + getLicenses(), 'error')
            else:
                WriteFile("/var/www/MyIPPbx"+ "/sipnumlicenses.jx", action)
                self.message_user(u'licence导入成功!', 'success')
        return super(LicenceAdmin, self).post(request, args, kwargs)
# 表单
#def mylicence_form(request):
#    return render_to_response('licence.html')
